package com.spring.design.factory.factorymethod;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public abstract class OrderPizza {

    //定义抽象方法,让工厂子类实现
    abstract Pizza createPizza(String orderType);

    public OrderPizza(){
        Pizza pizza = null;
        String orderType;

        do{
            orderType = getType();
            pizza = createPizza(orderType);//抽象方法，子类实现

            //输出pizza制作过程
            pizza.prepare();
            pizza.bake();
            pizza.cut();
            pizza.box();
        }while (true);
    }

    public String getType(){
        try {
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("写入pizza种类");
            String orderType = bufferedReader.readLine();
            return orderType;
        } catch (IOException e){
            e.printStackTrace();
            return "";
        }
    }

}
